/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package models;

/**
 *
 * @author pelle
 */
public class OrderItem {

    private Product product = null;
    private int quantity = 0;
    private float subTotal = 0;

    public OrderItem(Product product, int quantity) {
        this.product = product;
        this.quantity = quantity;

        this.calculateSubTotal();
    }

    private void calculateSubTotal() {
        this.subTotal = this.getProduct().getSalesPrice() * this.getQuantity();
    }

    public void plusQuantity() {
        this.quantity++;
        this.calculateSubTotal();
    }

    public void minusQuantity() {
        this.quantity--;
        this.calculateSubTotal();
    }

    /**
     * @return the product
     */
    public Product getProduct() {
        return product;
    }

    /**
     * @param product the product to set
     */
    public void setProduct(Product product) {
        this.product = product;
    }

    /**
     * @return the quantity
     */
    public int getQuantity() {
        return quantity;
    }

    /**
     * @param quantity the quantity to set
     */
    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    /**
     * @return the subTotal
     */
    public float getSubTotal() {
        return subTotal;
    }

    
}
